Imports System.Xml.Serialization
Imports EdmxEditor.CodeGeneration

Namespace CSDL

    Public Class ComplexType
        Inherits XEntityModelElementWithDocumentationBase

        ''' <summary>Initializes an instance of the <see cref="ComplexType" /> class.
        ''' This is the default constructor for this class.</summary>
        Public Sub New()
            MyBase.New("ComplexType", EdmXmlNamespace)
        End Sub

        ''' <summary>Initializes an instance of the <see cref="ComplexType" /> class.</summary>
        ''' <param name="other">An <see cref="System.Xml.Linq.XElement"/> object to copy from.</param>
        Public Sub New(ByVal other As XElement)
            MyBase.New(other)
            If (String.Compare(other.Name.NamespaceName, EdmXmlNamespace, StringComparison.OrdinalIgnoreCase) <> 0) Then
                Throw New ArgumentException("The element namespace must be " & EdmXmlNamespace, "other")
            End If
        End Sub

        Private __property As ComplexTypePropertyCollection

        <AutoLoad()> _
        <XmlElement("Property", GetType(ComplexTypeProperty))> _
        Public ReadOnly Property Properties() As ComplexTypePropertyCollection
            Get
                If (__property Is Nothing) Then
                    __property = New EdmxEditor.CSDL.ComplexTypePropertyCollection(Me, MyBase.Name.Namespace, "Property")
                End If
                Return __property
            End Get
        End Property

        <XmlAttribute()> _
        Public Shadows Property Name() As String
            Get
                Return Me.@Name
            End Get
            Set(ByVal value As String)
                Me.@Name = value
            End Set
        End Property

        <XmlAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Qualified, [Namespace]:=CodeGenerationXmlNamespace)> _
        Public Property TypeAccess() As PublicOrInternalAccess
            Get
                Return GetEnumValueAttribute(GetType(PublicOrInternalAccess), Me.Attribute(XName.Get("TypeAccess", CodeGenerationXmlNamespace)))
            End Get
            Set(ByVal value As PublicOrInternalAccess)
                If (Me.Attribute(XName.Get("TypeAccess", CodeGenerationXmlNamespace)) Is Nothing) Then
                    Me.Add(New XAttribute(XName.Get("TypeAccess", CodeGenerationXmlNamespace), ""))
                End If
                SetEnumValueAttribute(GetType(PublicOrInternalAccess), Me.Attribute(XName.Get("TypeAccess", CodeGenerationXmlNamespace)), value)
            End Set
        End Property

    End Class

End Namespace